This package is called spherical.kde. To install, run
the following code (in R):
Upon completion, you can run the following code (in R):
This is a demo vignette for our package. We will use earthquake data with 77 observations contained in the ’spherepc’ package for demonstration. The data record significant earthquakes (8+ Mb magnitude) around the Pacific Ocean since 1900, collected by the U.S. Geological Survey. The data have longitude and latitude coordinates.
library(spherepc)
# Import earthquake data and select longitude and latitude coordinates
data(Earthquake)
earthquake <- cbind(Earthquake$long, Earthquake$lat)
head(earthquake)
#> [,1] [,2]
#> [1,] -177.657 -28.427
#> [2,] -176.461 -31.080
#> [3,] -175.626 51.499
#> [4,] -174.776 51.520
#> [5,] -174.123 -20.187
#> [6,] -173.562 -14.739We want to transform spherical coordinates (longitude, latitude) to 3-dim Euclidean coordinates for analysis.
earthquake_Euc <- spherical.kde::transform_coordinates(earthquake)
head(earthquake_Euc)
#> x y z
#> [1,] -0.8786891 -0.03595233 -0.4760387
#> [2,] -0.8548141 -0.05286672 -0.5162344
#> [3,] -0.6207152 -0.04747810 0.7825973
#> [4,] -0.6196568 -0.05665491 0.7828254
#> [5,] -0.9336382 -0.09610335 -0.3450853
#> [6,] -0.9609961 -0.10843841 -0.2544163Then we could use cross validation to select the optimal smoothing parameter \(\kappa\).